package com.rules.admin.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rules.admin.dao.DataDictDetailModelDao;
import com.rules.admin.entity.DataDictDetailModel;
import com.rules.admin.service.DataDictDetailService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DataDictDetailServiceImpl extends ServiceImpl<DataDictDetailModelDao, DataDictDetailModel> implements DataDictDetailService {
   public IPage<DataDictDetailModel> queryPage(Long dataId, String dataName, IPage<DataDictDetailModel> page) {

      LambdaQueryWrapper<DataDictDetailModel> queryWrapper = new LambdaQueryWrapper<>();
      queryWrapper.eq(DataDictDetailModel::getDataId,dataId);
      if (StringUtils.isNotBlank(dataName)) {
         queryWrapper.like(DataDictDetailModel::getDataName,"%" + dataName + "%");
      }
      return this.page(page, queryWrapper);
   }



   public List<DataDictDetailModel> getAllByDataId(Long dataId) {
      LambdaQueryWrapper<DataDictDetailModel> queryWrapper = new LambdaQueryWrapper<>();
      queryWrapper.eq(DataDictDetailModel::getDataId,dataId);
      return this.baseMapper.selectList(queryWrapper);
   }
}
